perm filename ALIO.PAL[AL,HE]3 blob
sn#326336 filedate 1978-01-04 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00005 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 .SBTTL Basic TTY input and output routines
C00003 00003 TTY output routines TYPSTR, TYPDEC, TYPOCT, TYPCHR
C00008 00004 Macros: OUTSTR, NUMOUT, ASCIE, CRLF, ERRTRAP
C00012 00005 IOINIT, INSTR, system line buffers
C00015 ENDMK
C⊗;
.SBTTL Basic TTY input and output routines
.EVEN
; TTY output routines TYPSTR, TYPDEC, TYPOCT, TYPCHR
; Modified 5-Sep-74 by RF. Originally written by KKP.
COMMENT ⊗ Output a string, ending with a zero character. Pointer to
start of string in R0. Called in "simple" style. ⊗
TYPSTR: MOV R0,R1 ;R1 ← LOC[STRING]
BR 2$
1$: JSR PC,TYPCHR ;Type this one character
2$: MOVB (R1)+,R0 ;R0 ← Next byte of string
BNE 1$ ;If more to come, repeat.
RTS PC ;Done
COMMENT ⊗ Routines to output numbers. Argument in R0. TYPDEC
outputs in base 10, and TYPOCT in base 8. Both use TYPDIG as a
subroutine, putting the digit in R0. TYPCHR is a general purpose
character output routine. It looks at OUTSW to see where to direct
the output. ⊗
TYPDEC: MOV #12,RADIX ;To output in base 10
BR TYPDIG ;Go type it.
TYPOCT: MOV #8,RADIX ;To output in base 8.
BR TYPDIG ;Go type it.
TYPDIG: MOV R0,R1 ;Need dividend in R1, with R0 clear.
CLR R0 ;Clear upper half of dividend.
DIV (PC)+,R0 ;Divide argument in R0, R1 by radix.
RADIX: 12 ;Starts out in decimal.
BEQ TYPOUT ;If quotient zero, then can print.
MOV R1,-(SP) ;Else stack quotient
JSR PC,TYPDIG ;Recursive call.
MOV (SP)+,R1 ;Unstack last quotient
TYPOUT: ADD #'0,R1 ;Form TTY code for digit
MOV R1,R0 ;Need argument for TYPCHR in R0.
TYPCHR: TST OUTSW ;VT05 or console?
BEQ 3$ ;
TSTB KBOS ;VT05: Is it available?
BMI 2$ ;Yes.
1$:
.IFDF KERNEL
.IFNZ KERNEL
SLEEP #2 ;No. Sleep a while, try again
.ENDC
.ENDC
BR TYPCHR ;
2$: MOVB R0,KBOR ;Output a byte to it.
CMP #12,R0 ;Was it a line feed?
BNE TYPRET ;If not that code, then done.
CLR R0 ;Otherwise, output 3 nulls.
JSR PC,TYPCHR ;
JSR PC,TYPCHR ;
JMP TYPCHR ;Direct jump; it will return to caller.
3$: TSTB OREG ;Console: Ready?
BNE 1$ ;No.
MOV R0,OREG ;Yes. Output a byte to it.
MOV #1,172566 ;Wake up pdp10 by generating interrupt
TYPRET: RTS PC ;Return.
; Macros: OUTSTR, NUMOUT, ASCIE, CRLF, ERRTRAP
.MACRO OUTSTR B ;Type string starting at B.
MOV R0,-(SP) ;Save R0. Who knows what was happening in it?
MOV R1,-(SP) ;Save R1.
MOV #B,R0 ;Load up the string to be output
JSR PC,TYPSTR ;Call the string output utility routine.
MOV (SP)+,R1 ;Restore R1.
MOV (SP)+,R0 ;Restore R0.
.ENDM
.MACRO NUMOUT ;Type out the number in AC0 with CVG using OUTBUF
MOV R0,-(SP) ;Save the registers
MOV R1,-(SP)
STF AC0,-(SP)
STF AC1,-(SP)
MOV #OUTBUF,R0 ;Use OUTBUF to construct the string
JSR PC,CVG ;Convert floating point number to asc
LDF (SP)+,AC1 ;Restore the floating point registers
LDF (SP)+,AC0
MOV #OUTBUF,R0 ;Set pointer for i/o routine
JSR PC,TYPSTR ;Type out the number
MOV (SP)+,R1 ;Restore the registers
MOV (SP)+,R0
.ENDM
.MACRO ASCIE STR
.ASCIZ STR
.EVEN
.ENDM
.MACRO CRLF
OUTSTR CRLFX ;Carriage return, line feed.
.ENDM
CRLFX: .ASCIZ /
/
RUGMES: ASCIE </π
--ONLY DDT CAN HELP YOU NOW!
π/>
ERRTRAP:
; Pointer to message is on stack. Print it, restore state, go to DDT
MOV R0,-(SP) ;Save R0.
MOV R1,-(SP) ;Save R1.
.IFDF KERNEL
.IFNZ KERNEL
EVWAIT CSLEVT ;Grab the console
.ENDC
.ENDC
MOV #CRLFX,R0 ;Move to new line
JSR PC,TYPSTR ;
MOV 6(SP),R0 ;Type out message
JSR PC,TYPSTR ;
MOV #RUGMES,R0 ;Type out RUGMES
JSR PC,TYPSTR ;
.IFDF KERNEL
.IFNZ KERNEL
EVSIG CSLEVT ;Release the console
.ENDC
.ENDC
MOV (SP)+,R1 ;Restore R1.
MOV (SP)+,R0 ;Restore R0.
MOV (SP)+,(SP) ;put return address only on stack.
BPT ;Breakpoint to DDT.
RTS PC ;Return to calling point.
PUTLOC LERRTRAP, ERRTRAP
; IOINIT, INSTR, system line buffers
CSLEVT: 0 ;Console interlock event
IOINIT:
.IFDF KERNEL
.IFNZ KERNEL
EVMAK ;
MOV (SP),CSLEVT ;
EVSIG ;Make a console interlock event
.ENDC
.ENDC
RTS PC ;
COMMENT ⊗ String byte pointer argument in R0. A carriage return is
assumed to be the activation character. A rubout is a deleting
backspace character. At the completion of this routine a null
character is placed at the end of the input string. R0 then points
to the null character. Registers used: R0 passes the argument, R1 is
garbaged. ⊗
INSTR: CLR CCNT ;RESET CHARACTER COUNT
IN2: TST OUTSW ;VT05 OR CONSOLE?
BEQ CONSIN
TSTB KBIS ;TEST IF KEYBOARD READY
BEQ IN2 ;WAIT TILL IT IS
MOVB KBIR,R1 ;GET A CHARACTER
BR GOTCAR
CONSIN: MOV IREG,R1 ;BYTE FROM PDP10?
BEQ IN2 ;NO
CLR IREG
GOTCAR: BIC #177600,R1 ;MASK OFF - MAKE IT 7 BITS
CMP R1,#177 ;COMPARE TO BS CHARACTER
BNE 1$ ;SKIP IF ITS NOT
TST CCNT ;CHECK IF ANY CHARACTERS IN BUFFER
BEQ IN2 ;FORGET BACK SPACE IF NO CHAR.
DEC R0 ;REMOVE LAST CHARACTER IN BUFFER
DEC CCNT ;DECREMENT CHARACTER COUNT
OUTSTR DBS ;PERFORM A DELETING BACKSPACE
BR IN2
1$: CMP R1,#15 ;COMPARE TO CR CHARACTER
BEQ 2$ ;CONTINUE READING IF ITS NOT A CR
CMP R1,#40 ;CHECK IF CHARACTER LEGAL
BLT IN2 ;IGNOR IF IT IS
MOVB R1,(R0)+ ;SAVE THE CHARACTER
INC CCNT ;INCREMENT CHARACTER COUNT
MOV R0,-(SP) ;ECHO THE CHARACTER
MOV R1,R0
JSR PC,TYPCHR
MOV (SP)+,R0
BR IN2 ;CONTINUE READING
2$: CRLF ;IF IT IS A CR, TYPE A CR AND LF
MOVB R1,(R0)+ ;PUT A CR IN THE STRING
MOVB #0,(R0) ;PUT IN A NULL CHARACTER
RTS PC ;RETURN
CCNT: 0
DBS: .BYTE 10,40,10,0
;System line buffers
INBUF: .BLKW 42.
OUTBUF: .BLKW 42.
CURIN: INBUF ;Current line pointer